const Utils = {
	isBlank: str => {
		if (str === undefined || str === null) {
			return true;
		}
		if (typeof str === 'string' && str.trim() === '') return true;
	},

	forEachDetail(detailMark, callback) {
		if (Utils.isBlank(detailMark)) return;
		const detail = /detail_\d/.test(detailMark) ? detailMark : `detail_${detailMark}`
		const form = Utils.getForm();
		const allRows = form.getDetailAllRowIndexStr(detail);
		if (allRows === '') return;
		allRows.split(',').forEach(callback)
	},

	getForm: () => window.WfForm || window.ModeForm,

	toggleDetail: (detailId, show) => {
		const dom = document.querySelector(`#dTableArea_${detailId-1}`)
		if (dom) {
			const pNode = dom.parentNode;
			if (pNode) pNode.style.display = show ? '' : 'none'
		}
	}
}

ecodeSDK.exp(Utils)